package com.ybu.oodd.controller;

import com.ybu.oodd.pojo.HomeNum;
import com.ybu.oodd.pojo.HomeText;
import com.ybu.oodd.pojo.Result;
import com.ybu.oodd.service.HomeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/home")
@Slf4j
public class HomeController {

    @Autowired
    private HomeService homeService;

    /*
     * 查询统计数据
     * */
    @GetMapping("/num")
    public Result getHomeNum(){
        log.info("统计数据");
        HomeNum homeNum = homeService.getHomeNumByRedis();
        return Result.success("获取成功",homeNum);
    }

    /*
     * 查询主页信息
     * */
    @GetMapping("/text")
    public Result getHomeText(){
        log.info("查询主页文字");
        HomeText homeText = homeService.getHomeTextByRedis();
        return Result.success("获取成功",homeText);
    }
}
